package main

import (
	"github.com/gin-gonic/gin"
	"log"
)

func Registering(c *gin.Context) {
	var para struct{
		Username string `json:"username"`
		Password string `json:"password"`
	}
	err := c.Bind(&para)
	if err != nil {
		log.Println(err)
		c.String(503, "%s", "error")
		return
	}
	err = addUser(para.Username, para.Password)
	if err != nil {
		log.Println(err)
		c.String(403, "%s", "name has been used")
		return
	}
	c.String(200, "%s", "register success!")
	log.Println("register success")
}
